package myta.base;

import myta.service.Database;
import myta.service.Utility;


public abstract class FormBase implements FormInterface {
	public String formName;
	
	public FormBase() {
		try {
			if(Database.dbConnection == null){
				Database.connectToDatabase();
			}
			
			Utility.checkAuth();
			
			init();
			tampil();
		} catch (Exception e) {
			Utility.showMessage(e.getMessage());
		}
	}
	
	public String add(){
		Utility.setNew(true);
		return formName + "data.jsf?faces-redirect=true";
	}
	
	public String reload(){
		Utility.setNew(true);
		return formName+ ".jsf?faces-redirect=true";
	}
	
	public String edit(){
		Utility.setNew(false);
		return formName + "data.jsf";
	}
	
	public String delete(){
		try {
			hapus();
		} catch (Exception e) {}
		
		return formName + ".jsf?faces-redirect=true";
	}
}
